﻿using Abp.Domain.Entities.Caching;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using Abp.Runtime.Caching;

namespace AbpProjectTemplate.Domain.Users
{
    public interface IUserCache : IEntityCache<User, long> { }

    public class UserCache : EntityCache<User, User, long>, IUserCache, Abp.Dependency.ITransientDependency
    {
        public UserCache(ICacheManager cacheManager, 
            IRepository<User, long> repository, 
            IUnitOfWorkManager unitOfWorkManager, 
            string cacheName = null) 
            : base(cacheManager, repository, unitOfWorkManager, cacheName)
        {
        }

        //public async Task<User> GetUser(int id)
        //{
        //    return await this.GetEntityFromDataSourceAsync(id);
        //}

        protected override User MapToCacheItem(User entity)
        {
            return entity;
        }
    }
}

